Vpa.doc.Class = function(className, parser){
    var p = className.lastIndexOf(".");
    if(p>-1){
        this.shortName = className.substring(p+1);
        this.pkg = className.substring(0,p);
    }else{
        this.shortName = className;
        this.pkg = '';
    }
    Vpa.apply(this,{
        className : className,
        parser : parser,
        isSingleton : false,
        description : '',
        configs : [],
        properties : [],
        methods : [],
        events : [],
        superClassName : '',
        superclasses : [],
        subclasses : [],
        href : "",
        html_filename: "",
        isPrivate : false,
        isStatic : false,
        constructor : null
    });
};

Vpa.doc.Class.prototype = {
    addComment : function(cmt){
        var types = Vpa.Comment.commentType;
        switch(cmt.commentType){
            case types.CLASS:
                this.addClass(cmt);
                break;
            case types.CLASS_INFO:
                this.addClassInfo(cmt);
                break;
            case types.CFG:
                this.addCfg(cmt);
                break;
            case types.CONSTRUCTOR:
                this.addConstructor(cmt);
                break;
            case types.EVENT:
                this.addEvent(cmt);
                break;
            case types.METHOD:
                this.addMethod(cmt);
                break;
            case types.PROPERTY:
                this.addProperty(cmt);
                break;
            default:
                break;
        }
    },
    addClass : function(cmt){
        var tag = cmt.getTag("class");
        this.description += (('' !== this.description) ? '\n' : '') + cmt.description;
        this.description += (('' !== this.description) ? '\n' : '') + tag.description;
        this.addClassInfo(cmt);
            
        this.html_filename = cmt.sourceFileName;
        this.href = cmt.sourceHref;
    
    },
    addClassInfo : function(cmt){
        this.isSingleton = cmt.isSingleton;
        this.isPrivate = !!cmt.isPrivate || !!cmt.isIgnored || !!cmt.isHidden || this.isPrivate;
        this.isStatic = cmt.isStatic;
        var superClassTag = cmt.getTag("extends");
        if(superClassTag)
            this.superClassName = superClassTag.superClassName;

        this.addCfg(cmt);
        this.addConstructor(cmt);
    },
    addConstructor : function(cmt){
        if(this.constructor){
            this.constructor.addInfo(cmt);
        }
        else{
            this.constructor = new Vpa.doc.Constructor(cmt);
        }
    },
    addCfg : function(cmt){
        var cfgs = cmt.getTags("cfg"),
            isIgnored = !!cmt.getTag("ignore"),
            isPrivate = !!cmt.getTag("private");
            
        for(var i=0,len=cfgs.length;i<len;i++){
            this.configs.push(new Vpa.doc.Cfg(cfgs[i], isIgnored, isPrivate,cmt));
        }
    },
    addEvent : function(cmt){
        this.events.push(new Vpa.doc.Event(cmt));
    },
    addMethod : function(cmt){
        var owner = cmt.getTag("member");
        if(owner && this.className != owner.ownerName){
            var ownerClass = this.parser.classes[owner.ownerName];
            if(ownerClass)
                ownerClass.addMethod(cmt);
            return;
        }
        this.methods.push(new Vpa.doc.Method(cmt));
    },
    addProperty : function(cmt){
        var owner = cmt.getTag("member");
        if(owner && this.className != owner.ownerName){
            var ownerClass = this.parser.classes[owner.ownerName];
            if(ownerClass)
                ownerClass.addProperty(cmt);
            return;
        }
        this.properties.push(new Vpa.doc.Property(cmt));
    }
};
